<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
/*
	获取数据
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'getone';
$return=array();
if($_RQ['op']=='getone'){
	$uid=intval($_RQ['uid']);
	$merchid=intval($_RQ['merchid']);
	$mobile=trim($_RQ['mobile']);
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if($uid){
		$params['id']=$uid;
	}
	if($mobile){
		if($mobile>100000000000 && !$merchid){
			$params['paycode']=$mobile;
		}else{
			$params['mobile']=$mobile;
		}
	}
	if($merchid){
		$mids=pdo_getall('core_members',$params,'id','id');
		if($mids){
			$mids=array_keys($mids);
		}else{
			$mids=-1;
		}
		$params2=array('uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid,'mid'=>$mids);
		$mid=pdo_getcolumn('jy_merch_member',$params2,'mid');
		$member=pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'id'=>$mid),array('nickname','mobile','id','avatar','from_os','credit2','paycode','paycodetime'));
	}
	if(!$merchid){
		$member=pdo_get('core_members',$params,array('nickname','mobile','id','avatar','from_os','credit2','paycode','paycodetime'));
	}
	if($params['paycode'] && $member['paycodetime']<time()-300){
		exi('付款码已过期！','error');
	}
	if(!$member){
		exi('没找到相关会员！','error');
	}
	$return['member']=$member;
	exi($return);
}
if($_RQ['op']=='getprovince'){
	$province=cfc('tools')->pcd();
	$data=array();
	foreach($province as $k=>$p){
		$newp=array('name'=>$k,'areas'=>array());
		foreach($p as $kc=>$c){
			$newc=array('name'=>$kc,'areas'=>array());
			foreach($c as $kd=>$d){
				$newd=array('name'=>$kd,'areas'=>array());
				foreach($d as $e){
					$newd['areas'][]=array('name'=>$e);
				}
				$newc['areas'][]=$newd;
			}
			$newp['areas'][]=$newc;
		}
		$data[]=$newp;
	}
	$res=array('province'=>$data);
	exi($res);
}
if($_RQ['op']=='getaddress'){
	$uid=intval($_RQ['uid']);
	$res['list']=pdo_getall('core_address',array('isdel'=>0,'mid'=>$uid?:$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	foreach($res['list'] as &$item){
		$item['pcd']=@json_decode($item['pcd'],true);
	}
	exi($res);
}